package com.leetcode.demo3Solution.java;

public class demo9HuiWen {
    public static void main(String[] args) {
          System.out.println(isPalindrome(78987));
    }
      static boolean isPalindrome(int x) {
        if(x<0||(x%10==0&&x!=0)) return false;
        int resNum=0;
        while (x>resNum){
             resNum=resNum*10+x%10;
             x/=10;
        }
        return  x==resNum || x==resNum/10;
    }
/*    public  static  boolean isPalindrome(int x) {
        //思考：这里大家可以思考一下，为什么末尾为 0 就可以直接返回 false
        if (x < 0 || (x % 10 == 0 && x != 0)) return false;
        int revertedNumber = 0;
        while (x > revertedNumber) {
            revertedNumber = revertedNumber * 10 + x % 10;
            x /= 10;
        }
        return x == revertedNumber || x == revertedNumber / 10;
    }*/

}
